<%@ page language="java" contentType="text/html;charset=UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = path + "/resource/extjs/skins/default";
%>
<html>
	<head>
		<jsp:include page="/common.jsp" />
		<!-- include common.jsp -->
		<base />
		<script type="text/javascript">
			var rightAreaId='<%=request.getParameter("rightAreaId")%>' ;
		</script>
		<script type="text/javascript">
		var basePath='<%=basePath%>';
		var path='<%=path%>';
		var store_right_area_pic;
		
		function deletePic(id){
			var r=confirm("确定要删除吗");
			if(r==true){
				Ext.Ajax.request({
					url:path+'/picture/deletePic.do',
					params:{"picId":id,"type":"right"},
					success:reload
				});
			}
		};
		function reload(){
			store_right_area_pic.load({
				callback:function(rec,opt){
					if(rec.length>=1){
						Ext.getCmp('upload').disabled=true;
					}else{
						Ext.getCmp('upload').disabled=false;
					}
				}
			});
		};
	    Ext.onReady(function(){
	    	store_right_area_pic=new Ext.data.Store({
	    		baseParams:{"rightAreaId":rightAreaId},
				proxy: new Ext.data.HttpProxy({
					url:path+'/picture/getRightAreaPicList.do'
				}),
				reader: new Ext.data.JsonReader({
					root:'root',
					fields:[
						{name:'picName'},
						{name:'picUrl'},
						{name:'picId'},
						{name:'opt'}
					]
				})
			});
			var grid_right_area_pic=new Ext.grid.GridPanel({
				//autoHeight:true,
				store:store_right_area_pic,
				border:false,
				autoScroll:true,
				height:220,
				viewConfig: { forceFit:true},
				columns:[
					{header:'名称',align:'center',dataindex:'picName'},
					{header:'位置',align:'center',dataindex:'picUrl'},
					{header:'操作',align:'center',dataindex:'opt',renderer:function(v1,v2,rec){
						return '<a href="javascript:void(0);" onclick="deletePic(\''+rec.data.picId+'\')">删除</a>'
					}}
				]
			});
			reload();
		    form__right_area_pic = new Ext.form.FormPanel({
	    		frame:true,
				border : false,
				renderTo:'upload_right_pic',
				id:'form__right_area_pic',
				//fileUpload:true,
				border:false,
				width:550,
				bodyStyle:'padding:10px 5px 0 20px',
				layout:'fit',
				items: [grid_right_area_pic],
		            buttons:[{
		            	text:'上传',
		            	id:'upload',
		            	handler:function(){
		            		var value=window.showModalDialog(path+'/manage/picture/uploadRightAreaPic.jsp?rightAreaId='+rightAreaId,'','dialogHeight=200px;dialogWidth=400px;toolbar=no;menubar=no;scrollbars=yes;resizable=no;location=no;status=no;');
		            		if(value=='true'){
		            			reload();
		            		}
		            	}
					}]
			});
			
			
		});
		</script>
	</head>
	<body>
		<style>
			body {
			margin: 0;
			padding: 0 0 12px 0;
			font-size: 12px;
			line-height: 22px;
			font-family: "宋体", "Arial Narrow";
			background: #fff;
		}
		</style>
		<div id="upload_right_pic">
		</div>
	</body>
</html>
